package com.yuyang.gulimall.search.controller;

import com.yuyang.gulimall.search.service.MallSearchService;
import com.yuyang.gulimall.search.vo.SearchParam;
import com.yuyang.gulimall.search.vo.SearchResult;
import org.apache.http.HttpRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.Mapping;
import org.springframework.web.bind.annotation.PostMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @author yu yang
 * @date 2023/1/13 -13:27
 */
@Controller
public class SearchController {
    @Autowired
    MallSearchService mallSearchService;
    @GetMapping(value = "/list.html")
    public String listPage(SearchParam param, Model model, HttpServletRequest httpServletRequest){
        param.set_queryString(httpServletRequest.getQueryString());
        SearchResult result = mallSearchService.search(param);
        model.addAttribute("result",result);
        return "list";
    }
}
